<template>
	<view class="container">
		<uni-section title="图" sub-title="" type="line">
			<image :src="'http://localhost:8090/'+food.icon" mode=""></image>
		</uni-section>
		<uni-section title="名称" sub-title="" type="line">
			<view class="">{{food.name}}</view>
		</uni-section>
		<uni-section title="类别" sub-title="" type="line">
			<view class="">{{food.type}}</view>
		</uni-section>
		<uni-section title="价格" sub-title="" type="line">
			<view class="">{{food.price}}</view>
		</uni-section>
		<uni-section title="描述" sub-title="" type="line">
			<view>{{food.description}}</view>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				food:{},
				id:''
			}
		},
		methods: {
			get(){
				uni.request({
					url: 'http://localhost:8090/foodapp/food/findone',
					method: 'POST',
					data: {
						id:this.id
					},
					success: res => {
						if(res.data.success){
							console.log("成功");
							this.food=res.data.data
							console.log(this.food);
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onLoad: function (option) { //option为object类型，会序列化上个页面传递的参数
				console.log(option.id); //打印出上个页面传递的参数
				
				 this.id=option.id
				 console.log(this.id);
				 
			},
	    onShow(){
			this.get()
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
